/* GUI CONVERTED from pppsrp10.p (converter v1.75) Tue Sep  5 17:12:22 2000 */
/* pppsrp10.p - ITEM/SITE PRODUCT STRUCTURE REPORT                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                   */
/* All rights reserved worldwide.  This is an unpublished work.          */
/* web convert pppsrp10.p (converter v1.00) Fri Oct 10 13:57:15 1997     */
/* web tag in pppsrp10.p (converter v1.00) Mon Oct 06 14:17:38 1997      */
/*F0PN*/ /*K0ZN*/ /*                                                     */
/*V8:ConvertMode=FullGUIReport                                           */
/* REVISION: 7.0          LAST EDIT: 12/18/91          BY: emb           */
/* REVISION: 7.2      LAST MODIFIED: 10/18/94          BY: jzs *FS87*    */
/* REVISION: 7.5          LAST EDIT: 03/20/94 MODIFIED BY: dzs *J020*    */
/* REVISION: 8.5      LAST MODIFIED: 06/26/96 BY: *G1YQ* Julie Milligan  */
/* REVISION: 8.6      LAST MODIFIED: 10/15/97          BY:  mur *K0ZN*   */
/* REVISION: 7.4      LAST MODIFIED: 02/05/98 BY: *H1JC* Jean Miller     */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98 BY: *L007* A. Rahane       */
/* REVISION: 8.6E     LAST MODIFIED: 06/01/98 BY: *L03V* Brenda Milton   */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane*/
/* REVISION: 9.1      LAST MODIFIED: 08/13/00 BY: *N0KQ* myb             */
/* REVISION: 9.1      LAST MODIFIED: 08/21/00 BY: *N0MD* Mudit Mehta     */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

         {mfdtitle.i "b+ "}

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE pppsrp10_p_1 "Sort by Reference"
/* MaxLen: Comment: */

&SCOPED-DEFINE pppsrp10_p_4 "/no"
/* MaxLen: Comment: */

&SCOPED-DEFINE pppsrp10_p_5 "Levels"
/* MaxLen: Comment: */

&SCOPED-DEFINE pppsrp10_p_6 "Level"
/* MaxLen: Comment: */

&SCOPED-DEFINE pppsrp10_p_8 "New Page Each Parent"
/* MaxLen: Comment: */

&SCOPED-DEFINE pppsrp10_p_9 "Ph"
/* MaxLen: Comment: */

/*N0MD***********BEGIN COMMENTING*************
 * &SCOPED-DEFINE pppsrp10_p_2 "Rev: "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE pppsrp10_p_3 "BOM: "
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE pppsrp10_p_7 "Item not in inventory"
 * /* MaxLen: Comment: */
 *
 * &SCOPED-DEFINE pppsrp10_p_10 "PARENT"
 * /* MaxLen: Comment: */
 *N0MD***********END COMMENTING************* */

/* ********** End Translatable Strings Definitions ********* */

         define variable wonbr like wo_nbr.
         define variable wonbr1 like wo_nbr.

         define variable part like pt_part.
         define variable part1 like pt_part.

         define variable skpge like mfc_logical initial no label {&pppsrp10_p_8}.
         define variable sort_ref like mfc_logical initial no label {&pppsrp10_p_1}.

         define variable site like ptp_site.
         define variable site1 like ptp_site.

         define variable comp like ps_comp no-undo.
         define variable level as integer no-undo.
         define variable maxlevel as integer format ">>>" label {&pppsrp10_p_5}.
/*L03V*/ define variable eff_date like exr_start_date.
         define variable parent like ps_par no-undo.
         
         define variable desc1 like pt_desc1 format "x(24)" no-undo.
         define variable um like pt_um no-undo.
         define variable phantom like mfc_logical format "yes"
           label {&pppsrp10_p_9} no-undo.
         define variable iss_pol like pt_iss_pol format {&pppsrp10_p_4} no-undo.
         define variable record as integer extent 100 no-undo.
         define variable lvl as character format "x(10)" label {&pppsrp10_p_6}
           no-undo.
         define variable new_parent like mfc_logical no-undo.
         define variable lines as integer no-undo.
         define variable bom_code like pt_bom_code no-undo.
         define variable first-time as logical no-undo initial "yes".

         site = global_site.
         eff_date = today.

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
    wonbr        colon 22
    wonbr1        label {t001.i} colon 49
    part        colon 22
    part1        label {t001.i} colon 49
    site        colon 22
    site1        label {t001.i} colon 49
    SKIP(.4)  /*GUI*/
with frame a width 80 side-labels attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         {wbrp01.i}

         
/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:


            first-time = yes.

            /* INPUT FORM */
            if wonbr1 = hi_char then wonbr1 = "".
            if part1 = hi_char then part1 = "".
            if site1 = hi_char then site1 = "".

            if c-application-mode <> 'web' then
               
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


               {wbrp06.i &command = update &fields = "  wonbr wonbr1 part part1 site site1 " &frm = "a"}

               if (c-application-mode <> 'web') or
               (c-application-mode = 'web' and
               (c-web-request begins 'data')) then do:

                  bcdparm = "".
                  {mfquoter.i wonbr  }
                  {mfquoter.i wonbr1  }
                  {mfquoter.i part  }
                  {mfquoter.i part1  }
                  {mfquoter.i site     }
                  {mfquoter.i site1     }

                  if wonbr1 = "" then wonbr1 = hi_char.
                  if part1 = "" then part1 = hi_char.
                  if site1 = "" then site1 = hi_char.

               end. /* if c-application-mode */

               /* SELECT PRINTER */
               
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:

define buffer ptmstr for pt_mstr.


               {mfphead.i}

        for each wo_mstr no-lock where wo_nbr >= wonbr and wo_nbr <= wonbr1 :

               for each pt_mstr no-lock
               where pt_part = wo_part:

                  assign comp     = pt_part
                         phantom  = pt_phantom
                         bom_code = if pt_bom_code <> ""
                                       then pt_bom_code else pt_part
                         maxlevel = min(maxlevel,99)
                         level    = 1.

                  find ptp_det where ptp_part = pt_part
                                 and ptp_site = site
                  no-lock no-error.

                  if available ptp_det then
                     assign
                        bom_code = if ptp_bom_code <> "" then ptp_bom_code
                                   else ptp_part.

                     comp = bom_code.

                  if sort_ref then
                     find first ps_mstr use-index ps_parref where ps_par = comp
                     and ps_ps_code <> "J"
                     no-lock no-error.
                  else
                     find first ps_mstr use-index ps_parcomp
                     where ps_par = comp
                     and ps_ps_code <> "J"
                     no-lock no-error.
                  if not available ps_mstr then next.

                  assign parent     = pt_part
                         phantom    = if available ptp_det then ptp_phantom
                                      else phantom
                         iss_pol    = if available ptp_det then ptp_iss_pol
                                      else pt_iss_pol.
                         new_parent = yes.

                  repeat with frame det2 down:

                     /*DETAIL FORM */
                     FORM /*GUI*/ 
                        ps_comp
                        ps_ref
                        desc1
                        ps_qty_per
                        um
                        ps_op
                     with STREAM-IO /*GUI*/  frame det2 width 132 no-attr-space no-box.

                     /* SET EXTERNAL LABELS */
                     setFrameLabels(frame det2:handle).

                     if new_parent = yes then do:

                        if page-size - line-counter < 7 then page.

                        if not first-time then do:
                           if skpge then page.
                           else down 1.
                        end.
                        first-time = no.

                        find bom_mstr where
                        bom_parent = if pt_bom_code <> "" then pt_bom_code
                                     else pt_part no-lock no-error.

                        if available bom_mstr then um = bom_batch_um.
                        else um = pt_um.

                        display
/*N0MD*                    {&pppsrp10_p_10} @ lvl */
/*N0MD*/                   caps(getTermLabel("PARENT",10)) @ lvl
                           parent @ ps_comp
                           pt_desc1 @ desc1
                           um
                           phantom @ phantom
                           iss_pol WITH STREAM-IO /*GUI*/ .

                        down 1.

                        if available pt_mstr and pt_desc2 > "" then do:
                           display  pt_desc2 @ desc1 WITH STREAM-IO /*GUI*/ .
                           down 1.
                        end.

                        if available ptp_det then do:
                           if ptp_rev <> "" then do:
/*N0MD*                       display {&pppsrp10_p_2} + */
/*N0MD*/                      display getTermLabel("REVISION",7) + ": " +
                              ptp_rev format "x(24)" @ desc1 WITH STREAM-IO /*GUI*/ .
                              down 1.
                           end.
                        end.
                        else
                        if available pt_mstr and pt_rev <> "" then do:
/*N0MD*                    display {&pppsrp10_p_2} + */
/*N0MD*/                   display getTermLabel("REVISION",7) + ": " +
                           pt_rev format "x(24)" @ desc1 WITH STREAM-IO /*GUI*/ .
                           down 1.
                        end.
                        if bom_code <> parent then do:
/*N0MD*                    display {&pppsrp10_p_3} + bom_code @ desc1. */
/*N0MD*/                   display getTermLabel("BILL_OF_MATERIAL",4) + ": "
/*N0MD*/                   + bom_code @ desc1 WITH STREAM-IO /*GUI*/ .
                           down 1.
                        end.
                        new_parent = no.
                     end.  /* IF new_parent */

                     if not available ps_mstr then do:
                        repeat:
                           level = level - 1.
                           if level < 1 then leave.
                           find ps_mstr where recid(ps_mstr) = record[level]
                           no-lock no-error.
                           comp = ps_par.
                           if sort_ref then
                              find next ps_mstr use-index ps_parref where
                              ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                           else
                              find next ps_mstr use-index ps_parcomp
                              where ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                           if available ps_mstr then leave.
                        end.  /* REPEAT */
                     end.  /* IF NOT AVAILABLE pt_mstr */

                     if level < 1 then leave.

                     if eff_date = ? or (eff_date <> ? and
                     (ps_start = ? or ps_start <= eff_date)
                     and  (ps_end = ? or eff_date <= ps_end)) then do:

/*N0MD*                 assign um       = ""
 *N0MD*                        desc1    = {&pppsrp10_p_7} */
/*N0MD*/                assign desc1    = getTermLabel("ITEM_NOT_IN_INVENTORY",24)
/*N0MD*/                       um       = ""
                               iss_pol  = no
                               phantom  = no
                               bom_code = ps_comp.

                        find ptmstr where ptmstr.pt_part = ps_comp
                        no-lock no-error.
                        if available ptmstr then do:
                           assign um       = ptmstr.pt_um
                                  desc1    = ptmstr.pt_desc1
                                  iss_pol  = ptmstr.pt_iss_pol
                                  phantom  = ptmstr.pt_phantom
                                  bom_code = if pt_bom_code <> ""
                                                then pt_bom_code
                                             else pt_part.
                        end.  /* IF AVAILABLE pt_mstr */
                        else do:
                           find bom_mstr no-lock where bom_parent = ps_comp
                           no-error.
                           if available bom_mstr then
                              assign um       = bom_batch_um
                                     desc1    = bom_desc
                                     bom_code = bom_parent.
                        end.  /* ELSE DO */

                        find ptp_det no-lock where ptp_part = ps_comp
                        and ptp_site = site no-error.
                        if available ptp_det then
                           assign iss_pol  = ptp_iss_pol
                                  phantom  = ptp_phantom
                                  bom_code = if ptp_bom_code <> ""
                                                then ptp_bom_code
                                             else ptp_part.

                       record[level] = recid(ps_mstr).
                       lvl = "........".
                       lvl = substring(lvl,1,min (level - 1,9)) + string(level).
                       if length(lvl) > 10 then lvl =
                          substring(lvl,length (lvl) - 9,10).

                        lines = 1.
                        if ps_rmks > "" then lines = lines + 1.
                        if available ptmstr and ptmstr.pt_desc2 > ""
                           then lines = lines + 1.
                        if available ptp_det and ptp_rev > ""
                           then lines = lines + 1.
                        else
                        if available ptmstr and ptmstr.pt_rev > ""
                           then lines = lines + 1.
                        if page-size - line-counter < lines then page.

                        display ps_comp ps_ref desc1 ps_qty_per 
                           um
                           ps_op
                        with frame det2 STREAM-IO /*GUI*/ .

                        if level < maxlevel or maxlevel = 0 then do:
                           comp = bom_code.
                           level = level + 1.
                           if sort_ref then
                              find first ps_mstr use-index ps_parref
                              where ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                           else
                              find first ps_mstr use-index ps_parcomp
                              where ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                        end.
                        else do:
                           if sort_ref then
                              find next ps_mstr use-index ps_parref
                              where ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                           else
                              find next ps_mstr use-index ps_parcomp
                              where ps_par = comp
                              and ps_ps_code <> "J"
                              no-lock no-error.
                        end.
                     end. /* if effective date */
                     else do:
                        if sort_ref then
                           find next ps_mstr use-index ps_parref
                           where ps_par = comp
                           and ps_ps_code <> "J"
                           no-lock no-error.
                        else
                           find next ps_mstr use-index ps_parcomp
                           where ps_par = comp
                           and ps_ps_code <> "J"
                           no-lock no-error.
                     end.
                  end. /* repeat with frame det2 */

                  
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


               end.  /* FOR EACH pt_mstr */

        end. /* for each wo_mstr */

               
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


            end. /* repeat */

            {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" wonbr wonbr1 part part1 site site1  "} /*Drive the Report*/
